package com.zhangyj.impl.component;

import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;

public class GenaralUtil {
	public static void printSelect(String name,List<String[]> list,String value,Writer writer) throws IOException{
		writer.append("<select name=\"").append(name).append("\">");
		writer.append("<option></option>");
		Iterator<String[]> iter= list.iterator();
		while(iter.hasNext()) {
			writer.append("<option value=\"");
			String [] val = iter.next();
			writer.append(val[0]).append("\"");
			if (val[0].equals(value)) {
				writer.append(" selected=\"selected\"");
			}
			writer.append(">").append(val[1]).append("</option>");
		}
		writer.append("</select>");
	}
}
